<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="__STATIC__/js/jquery.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <script type="text/javascript" src="__STATIC__/x-admin/js/xadmin.js"></script>
    <link rel="stylesheet" href="__STATIC__/x-admin/css/font.css">
    <link rel="stylesheet" href="__STATIC__/x-admin/css/xadmin.css">
    <link rel="stylesheet" href="__STATIC__/layui/css/layui.css">
</head>
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="#">基础设置</a>
        <a href="#">地区管理</a>
          <a href="#">添加市</a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:window.location.reload();" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div style="height: 50px"></div>
<div style="width: 500px">
<form class="layui-form" action="" name="type" onclick="return false" id="city">
    <div class="layui-form-item">
        <label class="layui-form-label">市</label>
        <div class="layui-input-inline">
            <select name="city">
                {foreach $data as $value}
                    <option value="{$value.id}">{$value.region_name}</option>
                {/foreach}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">项目</label>
        <div class="layui-input-block">
            {foreach $project as $value}
                <input type="checkbox" id="project_id" name="project_id[]" value="{$value.id}" title="{$value.title}">
            {/foreach}
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" id="opening">开通</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</div>
</body>
<script>
    $("#opening").click(function(){
        if(!$("input[type=checkbox]:checked").val()){
            layer.msg('请选择开通的项目',{icon:5,time:2000});
            return;
        }
        $.ajax({
            url:"{:url('/region/openingCity')}",
            data:$("#city").serialize(),
            type:"post",
            dataType:"json",
            success:function(res){
                if(res.code){
                    layer.msg(res.msg,{icon:1,time:2000},function(){
                        window.type.reset();
                    });
                }else{
                    layer.msg(res.msg,{icon:5,time:2000});
                }
            }
        });
    });
</script>
</html>